/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.wpi.first.wpilibj.templates.subsystems;

import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.command.Subsystem;
import edu.wpi.first.wpilibj.templates.RobotMap;
import java.util.Vector;

/**
 *
 * @author Admin
 */
public class Solenoids extends Subsystem {
    
    Vector solenoidList;        // Will hold the solenoids in order.
    
    public Solenoids()
    {
        // Create a list of the solenoids so we can refer to them by index.
        solenoidList = new Vector(Solenoid.kSolenoidChannels);
        
        // Create each Solenoid and add it to the list.
        for(int i = 0; i < Solenoid.kSolenoidChannels; i++)
        {
            solenoidList.addElement(new Solenoid(RobotMap.solenoidModule, i + 1));
        }
    }
    public void initDefaultCommand() {
        // Set the default command for a subsystem here.
        //setDefaultCommand(new MySpecialCommand());
    }
    public void toggleSolenoid(int solenoidIndex)
    {
        if((solenoidIndex < 1) || (solenoidIndex > Solenoid.kSolenoidChannels))
            return;
        
        Solenoid theSolenoid = ((Solenoid) solenoidList.elementAt(solenoidIndex - 1));
        boolean isSet = theSolenoid.get();
        theSolenoid.set(!isSet);   // Toggle the solenoid.
        
    }
}
